package listfactory;

import factory.Item;
import factory.Page;

import java.util.Iterator;

public class ListPage extends Page {

    public ListPage(String title, String author){
        super(title,author);
    }

    @Override
    public String makeHTML() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("<html>");
        stringBuilder.append("<head>");
        stringBuilder.append("<title>");
        stringBuilder.append(title);
        stringBuilder.append("</title>");
        stringBuilder.append("</head>");
        stringBuilder.append("<body>");
        stringBuilder.append("<ul>");
        Iterator<Item> iterator = items.iterator();
        while (iterator.hasNext()){
            Item item = iterator.next();
            stringBuilder.append(item.makeHTML());
        }
        stringBuilder.append("</ul>");
        stringBuilder.append("<hr>");
        stringBuilder.append("<address>");
        stringBuilder.append(author);
        stringBuilder.append("</address>");
        stringBuilder.append("</body>");
        stringBuilder.append("</html>");
        return stringBuilder.toString();
    }

}
